package cn.itsub.proxy.server.work.config;

import cn.itsub.proxy.server.app.mapper.ClientMapper;
import cn.itsub.proxy.server.work.ProxyServerStarter;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class ContainerConfig implements ApplicationRunner {

    @Autowired
    ClientMapper clientMapper;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("Spring环境启动完成");
        ProxyServerStarter container = new ProxyServerStarter();
        container.start();
        //初始化更新映射
        ProxyConfig.getInstance().update2();
        log.info("内网穿透引擎启动完成");


        var list = clientMapper.selectAll();
        for (var client : list) {
            System.out.println(client.name);
        }
    }
}
